package com.mercury.pattern._01_singleton.lazy.type05;

/**
 * 懒汉式5：枚举式
 */
public class SingletonTest05 {
    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton instance2 = Singleton.INSTANCE;
        System.out.println(instance == instance2);
        System.out.println(instance.hashCode());
        System.out.println(instance2.hashCode());

        instance.hello();
    }
}

enum Singleton{
    INSTANCE;

    void hello(){
        System.out.println("hello world");
    }
}
